nclude<iostream>
using namespace std;

static int mArrnoleap[13]={0,31,59,90,120,151,181,212,243,273,304,334,365};
static int mArrleap[13]={0,31,60,91,121,152,182,213,244,274,305,335,366};

int main()
{
    int year=0;
    int month=0;
    int day=0;
    
    
    int i=0;
    int flag=0;
    
    while(cin>>year>>day)
    {
        month=0;
        i=0;
        flag=0;
        for(i=1;i<13;i++)
        {
        if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
            //下面这个是错的  所以记住要都分离开来
            //((year%4==0 && year%100!=0) || year%400==0 && month>2)//leap
        {
            flag=1;
            if(day<mArrleap[i])
                break;
        }
        else
        {
            flag=0;
            if(day<mArrnoleap[i])
                break;
        }
    }
    
    if(flag)//leap
        printf("%04d-%02d-%02d",year,i,day-mArrleap[i-1]);
    else
        printf("%04d-%02d-%02d",year,i,day-mArrnoleap[i-1]);
    }
    
    return 0;
}

<Paste>
